{include file='public/head' /}
<style type="text/css">
  .tablelist tr {
    border:1px solid #CFCFCF;
  }
  .tablelist tr td,.tablelist tr th{
    border:1px solid #CFCFCF;
  }
</style>
    <div class="col-sm-9 col-sm-offset-3 col-md-10 col-lg-10 col-md-offset-2 main" id="main" style="padding:10px">
        <h1 class="page-header">订单列表 <!-- <button type="button" class="btn btn-danger"  title="删除全部选中" id="deleteSelect">删除</button> -->
        </h1>
        <div class="table-responsive" style="margin-top: -30px;border:none;">
          <form action="{:url('admin/order/index')}" method="get" class="navbar-form navbar-right" role="search" style="margin-top: 20px;">
              
                  开始时间:<input name="startime" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
                  结束时间:<input name="endtime" type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})"/>
            

           <div class="input-group">
              <input type="text" class="form-control" autocomplete="off" placeholder="键入关键字搜索" value='{$Think.get.key}' name="key" style="width:190px">
            <span class="input-group">
             <input class="btn btn-primary" type="submit" value="搜索" style="border-radius: 0 3px 3px 0">&nbsp;
             <button class="btn btn-primary" name="all" value="1">显示全部</button>
              </span> 
            </div>  
           </form>
          <table class="table table-striped table-hover tablelist" >
            <thead>
              <tr style="background-color: #3399CC;color: white">
                <th><input type="checkbox" id="all" style="position: relative;top:2px"/><span class="glyphicon glyphicon-th-large"></span> <span >选择</span></th>
                <th><span class="glyphicon glyphicon-user"></span> <span>用户名</span></th>
                <th><span class="glyphicon glyphicon-map-marker"></span> <span>订单号</span></th>
                <th><span class="glyphicon glyphicon-map-marker"></span> <span>期数</span></th>
                <th><span class="glyphicon glyphicon-tags"></span> <span>下单金额</span></th>
                <th><span class="glyphicon glyphicon-flag"></span> <span>涨跌</span></th>
                <th><span class="glyphicon glyphicon-repeat"></span> <span>状态</span></th>
                <th><span class="glyphicon glyphicon-education"></span> <span>收益</span></th>
                <th><span class="glyphicon glyphicon-time"></span> <span>下注时间</span></th>
               <!--  <th><span class="glyphicon glyphicon-pencil"></span> <span>操作</span></th> -->
              </tr>
            </thead>
            <tbody>
              {volist name="data" id="vo"}
              <tr>
                <td><input type="checkbox" class="input-control" value="{$vo.oid}"/>{$vo.oid}</td>
                <td>{$vo.username}</td> 
                <td>{$vo.codeifd}</td>
                <td>{$vo.qishu}</td>
                <td>{$vo.money}</td>
                <td>
                  {if condition="$vo.updown eq 1"}
                  买涨
                  {else /}
                  买跌
                  {/if}
                </td>
                <td>
                  {if condition="$vo.status eq 1"}
                  <span style="color:red">已中奖</span>
                  {elseif condition="$vo.status eq 0"}
                  <span style="color:red">未中奖</span>
                  {else /}
                   <span style="color:red">未开奖</span>
                  {/if}
                </td>
                <td>{$vo.winmoney}</td>
                <td>{$vo.ordertime}</td>
           <!--      <td><a rel="1" class="btn btn-primary btn-xs" name="see">查看</a> <a  class="btn btn-success btn-xs del" href="{:url('del',['oid'=>$vo['oid']])}">删除</a></td> -->
              </tr>  
              {/volist}
              <tr><td colspan="10" style="color: red"><span style="float: right;">订单总计 : {$moneys} | 收益总计 : {$winmoneys}&nbsp;</span></td></tr>
            </tbody>
          </table>
        </div>
        <footer class="message_footer" style="margin-top: -10px;">
        {if condition="$all eq 1"}
        {else/}
        <span style="float: left;margin-top: 15px;">第{$data->currentPage()} 页 / 共 {$data->lastPage()} 页 ( 总 共 {$data->total()} 条 记 录 )</span> 
        <div style="float: right;margin-top: -10px;">  
        <div class="page" style="margin-top: 5px;">
        {$data->render()}
        </div>
        </div>
        {/if}
        </footer>
    </div>
  </div>
</section>
<script>
  //单条记录删除
  $('.del').click(function(){
      var del = confirm("你确定要删除吗？");
       if(del == false){
        return false;
      }  
  });
  //多选删除
  $('#deleteSelect').click(function(){
    //获取【被选择】的行的id
      var trObj = $(".tablelist tbody tr");
      var ids = new Array();
      var mainObjs = new Array();
      //遍历每一行
      for($i=0;$i<trObj.length;$i++){
         if(trObj.eq($i).find("input").attr('checked')){
            //组装ids数组
            ids[ids.length]=trObj.eq($i).find("input").val();
            //组装mainObj数组
            mainObjs[mainObjs.length]=trObj.eq($i);
         }
      }   
    if(ids.length>0){
        //启动ajax
        $.ajax({
            url:"{:url('deleteall')}",
            type:'post',
            data:{'id':ids},
            async:false, 
            dataType:'json',
            success:function (d) {
                console.log(d);
            if(d==1) {
                var a = confirm("你确定要删除吗？");
                if(a == true){
                   //将前端被选择的多选框所在的行移除DOM
                    for($i=0;$i<mainObjs.length;$i++){
                        mainObjs[$i].fadeOut(500,function(){
                            $(this).remove();
                            history.go(0);
                        });
                    }
                }else{
                   history.go(0);
                }
              } else if (d == 2) {
                     //删除失败
                   alert('删除失败');
               }

            }

        });
    }else{
       alert("你没有选择要删除的内容，请选择后再【批量删除】");
    }  
 
  });
  //全选或全不选
  $("#all").click(function(){ 
      if(this.checked){
         $(".tablelist tbody tr :checkbox").attr("checked", true);
        
      }else{
         $(".tablelist tbody tr :checkbox").removeAttr("checked", false);
      }
  });

// function f(){
//   window.location.href = "{:url('admin/order/index')}";
// }

// window.setInterval(f, 15000);
</script>
</body>
</html>
